home *** CD-ROM | disk | FTP | other *** search
/ Sky at Night 2007 August / SAN CD 8-2007 CD-ROM 27.iso / pc / Media / GlossaryDatabase.swf / scripts / frame_1 / DoAction.as
Encoding:
Text File  |  2006-05-30  |  2.0 KB  |  82 lines

  1. txtSearch.restrict = "A-Z a-z 0-9  ";
  2. var aSearchData = new Array();
  3. getList = function()
  4. {
  5.    oList.clearList();
  6.    var _loc2_ = 0;
  7.    var _loc4_ = new Array();
  8.    var _loc3_ = new String();
  9.    getKeyWords = function()
  10.    {
  11.       return txtSearch.text.split(" ");
  12.    };
  13.    _loc4_ = getKeyWords();
  14.    i = 0;
  15.    while(i < aGlossaryData.length)
  16.    {
  17.       _loc3_ = aGlossaryData[i][0];
  18.       j = 0;
  19.       while(j < _loc4_.length)
  20.       {
  21.          if(_loc3_.toLowerCase().indexOf(_loc4_[j].toLowerCase()) > -1)
  22.          {
  23.             aSearchData[_loc2_] = new Array(2);
  24.             aSearchData[_loc2_][0] = _loc3_;
  25.             aSearchData[_loc2_][1] = aGlossaryData[i][1];
  26.             oList.addToList(_loc3_);
  27.             _loc2_ = _loc2_ + 1;
  28.             break;
  29.          }
  30.          j++;
  31.       }
  32.       i++;
  33.    }
  34.    oScroller0.setScrollBar(this.oList.oListContainer,420,(_loc2_ - 1) * 30.3);
  35. };
  36. var i = 0;
  37. var aGlossaryItem = new XMLNode();
  38. var aGlossaryData = new Array();
  39. var oXML = new XML();
  40. oXML.ignoreWhite = true;
  41. oXML.onLoad = function(bOK)
  42. {
  43.    if(bOK)
  44.    {
  45.       for(i in this.firstChild.childNodes)
  46.       {
  47.          aGlossaryData[i] = new Array(2);
  48.          aGlossaryItem = this.firstChild.childNodes[i];
  49.          aGlossaryData[i][0] = aGlossaryItem.childNodes[0].firstChild.nodeValue;
  50.          aGlossaryData[i][1] = aGlossaryItem.childNodes[1].firstChild.nodeValue;
  51.       }
  52.       aGlossaryData.sort(Array.CASEINSENSITIVE);
  53.       getList();
  54.    }
  55. };
  56. oXML.load("gdb.xml");
  57. loadBody = function(iID)
  58. {
  59.    txtTitle.text = aSearchData[iID - 1][0];
  60.    txtBody.text = aSearchData[iID - 1][1];
  61. };
  62. oBttn.onPress = function()
  63. {
  64.    getList();
  65. };
  66. txtSearch.onKeyUp = function()
  67. {
  68.    oBttn.onPress();
  69. };
  70. Key.addListener(txtSearch);
  71. txtSearch.onMouseDown = function()
  72. {
  73.    var _loc1_ = new TextFormat();
  74.    _loc1_.color = 16763904;
  75.    txtSearch.backgroundColor = 16763904;
  76.    txtSearch.setTextFormat(_loc1_);
  77. };
  78. Mouse.addListener(txtSearch);
  79. txtSearch.onSetFocus = function()
  80. {
  81. };
  82.